//
//  HTMineViewController.m
//  HeartTravel
//
//  Created by lanou on 15/10/24.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "HTMineViewController.h"
#import "RegisterViewController.h"
#import "PersonalInformationViewController.h"

@interface HTMineViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UILabel *warningLable;
@property (nonatomic, strong) NSString *nickname;//用户名
@end

@implementation HTMineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = YES;
    self.titleLabel.text = @"登录";
}

//点击空白处回收键盘
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

//登陆
- (IBAction)login:(id)sender {
    
    NSString *name = [[NSUserDefaults standardUserDefaults]objectForKey:@"userName"];
    NSString *password = [[NSUserDefaults standardUserDefaults]objectForKey:@"password"];
    
    if ([_nameTF.text isEqualToString:name] && [_passwordTF.text isEqualToString:password]) {
        
        PersonalInformationViewController *personal = [[PersonalInformationViewController alloc]init];
        
        personal.name.text = _nameTF.text;
        
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"islogin"];
        [self.navigationController pushViewController:personal animated:YES];
        
    }else{
        //登陆失败，显示提示框，停留在登陆页面
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"用户名或密码错误！" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确认", nil];
        [alertView show];
    }
}


- (IBAction)registerId:(id)sender {
    RegisterViewController *registerVC = [[RegisterViewController alloc]init];
    [self.navigationController pushViewController:registerVC animated:YES];
   
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
